home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / intuition / drawborder.c < prev    next >
C/C++ Source or Header  |  1996-11-08  |  4KB  |  153 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: drawborder.c,v 1.5 1996/11/08 11:28:01 aros Exp $
  4.     $Log: drawborder.c,v $
  5.     Revision 1.5  1996/11/08 11:28:01  aros
  6.     All OS function use now Amiga types
  7.  
  8.     Moved intuition-driver protos to intuition_intern.h
  9.  
  10.     Revision 1.4  1996/10/24 15:51:18  aros
  11.     Use the official AROS macros over the __AROS versions.
  12.  
  13.     Revision 1.3  1996/10/02 18:10:47  digulla
  14.     Fixed a bug (coordinates are relative to offset and not to last point)
  15.  
  16.     Revision 1.2  1996/08/29 13:33:30  digulla
  17.     Moved common code from driver to Intuition
  18.     More docs
  19.  
  20.     Revision 1.1  1996/08/23 17:28:18  digulla
  21.     Several new functions; some still empty.
  22.  
  23.  
  24.     Desc:
  25.     Lang: english
  26. */
  27. #include "intuition_intern.h"
  28. #include <clib/graphics_protos.h>
  29.  
  30. /*****************************************************************************
  31.  
  32.     NAME */
  33.     #include <graphics/rastport.h>
  34.     #include <intuition/intuition.h>
  35.     #include <clib/intuition_protos.h>
  36.  
  37.     AROS_LH4(void, DrawBorder,
  38.  
  39. /*  SYNOPSIS */
  40.     AROS_LHA(struct RastPort *, rp, A0),
  41.     AROS_LHA(struct Border   *, border, A1),
  42.     AROS_LHA(LONG             , leftOffset, D0),
  43.     AROS_LHA(LONG             , topOffset, D1),
  44.  
  45. /*  LOCATION */
  46.     struct IntuitionBase *, IntuitionBase, 18, Intuition)
  47.  
  48. /*  FUNCTION
  49.     Draws one or more borders in the specified RastPort. Rendering
  50.     will start at the position which you get when you add the offsets
  51.     leftOffset and topOffset to the LeftEdge and TopEdge specified
  52.     in the Border structure. All coordinates are relative to that point.
  53.  
  54.     INPUTS
  55.     rp - The RastPort to render into
  56.     border - Information what and how to render
  57.     leftOffset, topOffset - Initial starting position
  58.  
  59.     RESULT
  60.     None.
  61.  
  62.     NOTES
  63.  
  64.     EXAMPLE
  65.     // Draw a house with one stroke
  66.     // The drawing starts at the lower left edge
  67.     WORD XY[] =
  68.     {
  69.         10, -10,
  70.         10,   0,
  71.          0, -10,
  72.         10, -10,
  73.          5, -15,
  74.          0, -10,
  75.          0,   0,
  76.         10,   0,
  77.     };
  78.     struct Border demo =
  79.     {
  80.         100, 100,    // Position
  81.         1, 2,    // Pens
  82.         JAM1,    // Drawmode
  83.         8,        // Number of pairs in XY
  84.         XY,     // Vector offsets
  85.         NULL    // No next border
  86.     };
  87.  
  88.     // Render the house with the bottom left edge at 150, 50
  89.     DrawBorder (rp, &demo, 50, -50);
  90.  
  91.     BUGS
  92.  
  93.     SEE ALSO
  94.  
  95.     INTERNALS
  96.  
  97.     HISTORY
  98.     29-10-95    digulla automatically created from
  99.                 intuition_lib.fd and clib/intuition_protos.h
  100.  
  101. *****************************************************************************/
  102. {
  103.     AROS_LIBFUNC_INIT
  104.     AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  105.     ULONG  apen;
  106.     ULONG  bpen;
  107.     ULONG  drmd;
  108.     WORD * ptr;
  109.     WORD   x, y;
  110.     WORD   xoff, yoff;
  111.     int    t;
  112.  
  113.     /* Store important variables of the RastPort */
  114.     apen = GetAPen (rp);
  115.     bpen = GetBPen (rp);
  116.     drmd = GetDrMd (rp);
  117.  
  118.     /* For all borders... */
  119.     for ( ; border; border=border->NextBorder)
  120.     {
  121.     /* Change RastPort to the colors/mode specified */
  122.     SetAPen (rp, border->FrontPen);
  123.     SetBPen (rp, border->BackPen);
  124.     SetDrMd (rp, border->DrawMode);
  125.  
  126.     /* Move to initial position */
  127.     Move (rp
  128.         , x = border->LeftEdge + leftOffset
  129.         , y = border->TopEdge + topOffset
  130.     );
  131.  
  132.     /* Start of vector offsets */
  133.     ptr = border->XY;
  134.  
  135.     for (t=0; t<border->Count; t++)
  136.     {
  137.         /* Add vector offset to current position */
  138.         xoff = *ptr ++;
  139.         yoff = *ptr ++;
  140.  
  141.         /* Stroke */
  142.         Draw (rp, x + xoff, y + yoff);
  143.     }
  144.     }
  145.  
  146.     /* Restore RastPort */
  147.     SetAPen (rp, apen);
  148.     SetBPen (rp, bpen);
  149.     SetDrMd (rp, drmd);
  150.  
  151.     AROS_LIBFUNC_EXIT
  152. } /* DrawBorder */
  153.